package main

import "fmt"

func main() {

	v := Vertex{1, 2}

	fmt.Println(v)

	v.X = 3
	v.Y = 4

	fmt.Println(v)

	// 结构体指针
	p := &v

	// 结构体指针修改值
	(*p).Y = 10
	// 结构体指针的省略写法
	p.X = 1e9

	fmt.Println(v)

	fmt.Println("--------------------------------")

	test()
}

func test() {
	/// 结构体文法
	var (
		v1 = Vertex{1, 2}  // has type Vertex
		v2 = Vertex{X: 1}  // Y:0 is implicit
		v3 = Vertex{}      // X:0 and Y:0
		p  = &Vertex{1, 2} // has type *Vertex
	)

	fmt.Println(v1, p, v2, v3)
}

type Vertex struct {
	X int
	Y int
}
